<div class='resource-details'>
  <div class="row">
    <div class="col-sm-12">
      <h3>Status</h3>
      <dl class="dl-horizontal left">
        <dt>Status:</dt>
        <dd>
          <status-icon status="build.status.phase"></status-icon>
          <span ng-if="!build.status.message || build.status.phase === 'Cancelled'">{{build.status.phase}}</span>
          <span ng-if="build.status.message && build.status.phase !== 'Cancelled'">{{build.status.message}}</span>
          <span ng-if="build | jenkinsLogURL">
            <span class="text-muted">&ndash;</span>
            <a ng-href="{{build | jenkinsLogURL}}" target="_blank">View Log</a>
          </span>
        </dd>
        <dt>Started:</dt>
        <dd>
          <span ng-if="build.status.startTimestamp">
            <span am-time-ago="build.status.startTimestamp"></span>
            <span><span class="text-muted">&ndash;</span> {{build.status.startTimestamp | date : 'medium'}}</span>
          </span>
          <span ng-if="!build.status.startTimestamp"><em>not started</em></span>
        </dd>
        <dt>Duration:</dt>
        <dd>
          <span ng-switch="build.status.phase" class="hide-ng-leave">
            <span ng-switch-when="Complete">{{(build.status.startTimestamp || build.metadata.creationTimestamp) | duration : build.status.completionTimestamp}}</span>
            <span ng-switch-when="Failed">{{build.status.startTimestamp | duration : build.status.completionTimestamp}}</span>
            <span ng-switch-when="Running">running for <duration-until-now timestamp="build.status.startTimestamp"></duration-until-now></span>
            <span ng-switch-when="New">waiting for <duration-until-now timestamp="build.metadata.creationTimestamp"></duration-until-now></span>
            <span ng-switch-when="Pending">waiting for <duration-until-now timestamp="build.metadata.creationTimestamp"></duration-until-now></span>
            <span ng-switch-default>
              <span ng-if="build.status.startTimestamp">{{build.status.startTimestamp | duration : build.status.completionTimestamp}}</span>
              <span ng-if="!build.status.startTimestamp">waited for {{build.metadata.creationTimestamp | duration : build.status.completionTimestamp}}</span>
            </span>
          </span>
        </dd>
        <div ng-if='build.spec.triggeredBy.length'>
          <dt>Triggered By:</dt>
          <dd>
            <div ng-repeat="trigger in build.spec.triggeredBy">
              <div ng-switch="trigger.message">
                <span ng-switch-when="Manually triggered">Manual build</span>
                <span ng-switch-when="GitHub WebHook">
                  <ng-include src=" 'views/_webhook-trigger-cause.html' "></ng-include>
                </span>
                <span ng-switch-when="Generic WebHook">
                  <ng-include src=" 'views/_webhook-trigger-cause.html' "></ng-include>
                </span>
                <span ng-switch-when="Image change">
                  {{trigger.message}} for {{trigger.imageChangeBuild.fromRef.name}}
                </span>
                <span ng-switch-default ng-bind-html="trigger.message | linkify : '_blank'"></span>
              </div>
            </div>
          </dd>
        </div>
      </dl>
      <h3>Configuration <span class="small" ng-if="buildConfigName">created from <a href="{{build | configURLForResource}}">{{buildConfigName}}</a></span></h3>
      <dl class="dl-horizontal left">
        <dt>Build Strategy:</dt>
        <dd>{{build.spec.strategy.type | startCase}}</dd>
        <dt ng-if-start="(build | buildStrategy).from">Builder Image:</dt>
        <dd ng-if-end class="truncate">{{(build | buildStrategy).from | imageObjectRef : build.metadata.namespace}}<span ng-if="!(build | buildStrategy).from"><em>none</em></span></dd>
        <dt>Source Type:</dt>
        <dd>{{build.spec.source.type}}</dd>
        <dt ng-if-start="build.spec.source.git.uri">Source Repo:</dt>
        <dd ng-if-end><span class="word-break"><osc-git-link
                    uri="build.spec.source.git.uri"
                    ref="build.spec.source.git.ref"
                    context-dir="build.spec.source.contextDir">{{build.spec.source.git.uri}}</osc-git-link></span></dd>
        <dt ng-if-start="build.spec.source.git.ref">Source Ref:</dt>
        <dd ng-if-end>{{build.spec.source.git.ref}}</dd>
        <dt ng-if-start="build.spec.source.contextDir">Source Context Dir:</dt>
        <dd ng-if-end>{{build.spec.source.contextDir}}</dd>
        <dt ng-if-start="build.spec.revision.git.commit">Source Commit:</dt>
        <dd ng-if-end>
          <span class="word-break">
            {{build.spec.revision.git.message}}
          </span>
          <osc-git-link
            class="hash"
            uri="build.spec.source.git.uri"
            ref="build.spec.revision.git.commit">{{build.spec.revision.git.commit | limitTo:7}}</osc-git-link>
          <span ng-if="build.spec.revision.git.author">
            authored by {{build.spec.revision.git.author.name}}
          </span>
        </dd>
        <dt ng-if-start="outputTo = build.spec.output.to">Output Image:</dt>
        <dd ng-if-end>
          <a ng-if="outputTo.kind === 'ImageStreamTag' && (!outputTo.namespace || build.metadata.namespace === outputTo.namespace)"
              ng-href="{{outputTo.name | navigateResourceURL : 'ImageStreamTag' : build.metadata.namespace}}">
            {{outputTo | imageObjectRef : build.metadata.namespace}}
          </a>
          <span ng-if="outputTo.kind !== 'ImageStreamTag' || (outputTo.namespace && build.metadata.namespace !== outputTo.namespace)">
            {{outputTo | imageObjectRef : build.metadata.namespace}}
          </span>
        </dd>
        <dt ng-if-start="build.spec.output.pushSecret.name">Push Secret:</dt>
        <dd ng-if-end>{{build.spec.output.pushSecret.name}}</dd>
        <dt ng-if-start="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath">
          Jenkinsfile Path:
        </dt>
        <dd>
          <span ng-if="build | jenkinsfileLink">
            <a ng-href="{{build | jenkinsfileLink}}">{{build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath}}</a>
          </span>
          <span ng-if="!(build | jenkinsfileLink)">
            {{build.spec.strategy.jenkinsPipelineStrategy.jenkinsfilePath}}
          </span>
        </dd>
        <div ng-if-end class="small">
          <a href="" ng-click="showJenkinsfileExamples()">What's a Jenkinsfile?</a>
        </div>
        <div ng-if-start="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfile" class="small pull-right mar-top-sm">
          <a href="" ng-click="showJenkinsfileExamples()">What's a Jenkinsfile?</a>
        </div>
        <dt>
          Jenkinsfile:
        </dt>
        <dd></dd>
        <div ng-if-end ui-ace="{
          mode: 'groovy',
          theme: 'eclipse',
          showGutter: false,
          rendererOptions: {
            fadeFoldWidgets: true,
            highlightActiveLine: false,
            showPrintMargin: false
          },
          advanced: {
            highlightActiveLine: false
          }
        }" readonly ng-model="build.spec.strategy.jenkinsPipelineStrategy.jenkinsfile" class="ace-bordered ace-inline ace-read-only"></div>
      </dl>
      <div ng-if="build | hasPostCommitHook">
        <h3>Post-Commit Hooks</h3>
        <build-hooks build="build"></build-hooks>
      </div>
    </div>
  </div>
  <annotations annotations="build.metadata.annotations"></annotations>
</div>
